#!/bin/sh

cd /usr/local/cutedge/openvpn/scripts

if ( test `sysctl -n net.inet.ip.forwarding` == 1 ) then
    sysctl -w net.inet.ip.forwarding=0
    #sysctl -w net.inet.ip.fw.enable=0
fi

sed '/^###Start OpenVPNEnabler###/,/^###End OpenVPNEnabler###/d ; /^$/d' /etc/pf.conf > pf.tmp

mv pf.tmp /etc/pf.conf

pfctl -d
sleep 1
pfctl -F all
sleep 1
pfctl -f /etc/pf.conf -e
